package top.zhangjianyong.blog.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 防盗链配置类
 *
 * @author zhangjianyong
 * @since 2024/12/19
 */
@Data
@Component
@ConfigurationProperties(prefix = "blog.anti-hotlink")
public class AntiHotlinkConfig {

    /**
     * 是否启用防盗链功能
     */
    private boolean enabled = true;

    /**
     * 允许的域名列表
     */
    private List<String> allowedDomains = List.of(
        "localhost",
        "127.0.0.1",
        "zhangjianyong.top",
        "www.zhangjianyong.top",
        "blog.zhangjianyong.top"
    );

    /**
     * 签名密钥
     */
    private String secretKey = "blog_file_access_secret_key_2024";

    /**
     * 签名有效期（秒）
     */
    private int signatureExpireSeconds = 3600;

    /**
     * 是否允许空Referer（直接访问）
     */
    private boolean allowEmptyReferer = false;

    /**
     * 是否启用签名验证
     */
    private boolean enableSignature = true;

    /**
     * 是否启用Referer验证
     */
    private boolean enableReferer = true;
} 